import { SwfFrames } from "../scene/modle/frames/SwfFrames";
import { FrameTypeConfig } from "./FrameTypeConfig";
import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
//class ModleFrameConfig
    
    export  class ModleFrameConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            if (ModleFrameConfig._instance != null) 
            {
                throw new Error(" ModleFrameConfig 单例 ");
            }
            this.init();
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc4=null;
            var loc5=null;
            if (typeof arg1.modle === "array") 
            {
                loc4 = arg1.modle;
            }
            else 
            {
                loc4 = [arg1.modle];
            }
            var loc6=0;
            var loc7=loc4;
            for(loc5 of loc7) 
            {
                loc1 = new SwfFrames(loc5.frameType, loc5.name);
                loc1.createAction(loc5);
                this._map[loc1.name] = loc1;
            }
            return;
        }

        /* internal  */writeImpl(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=null;
            var loc4=null;
            var loc5=null;
            if (typeof arg1.modle === "array") 
            {
                loc4 = arg1.modle;
            }
            else 
            {
                loc4 = [arg1.modle];
            }
            var loc6=0;
            var loc7=loc4;
            for(loc5 of loc7) 
            {
                loc1 = FrameTypeConfig.instance.getFramesByName(loc5.type).clone();
                loc1.name = loc5.name;
                if (loc5.hasOwnProperty("pointY")) 
                {
                    loc1.pointY = loc5.pointY;
                }
                if (loc5.hasOwnProperty("modleType")) 
                {
                    loc1.modleType = loc5.modleType;
                }
                if (loc5.hasOwnProperty("isSouthTop")) 
                {
                    loc1.isSouthTop = loc5.isSouthTop;
                }
                if (loc5.hasOwnProperty("isNorthTop")) 
                {
                    loc1.isNorthTop = loc5.isNorthTop;
                }
                this._map[loc5.name] = loc1;
            }
            return;
        }

        public init(): void
        {
            var loc1=ConfigManager.instance.getObjectByFileName("modleFrame.xml");
            this.writeImpl(loc1);
            return;
        }

        public getFramesByName(arg1: string): SwfFrames
        {
            return this._map[arg1];
        }

        public static get instance(): ModleFrameConfig
        {
            if (ModleFrameConfig._instance == null) 
            {
                ModleFrameConfig._instance = new ModleFrameConfig();
            }
            return ModleFrameConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ static /* var */_instance: ModleFrameConfig;
    }
